package com.iweb.resp;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.Collections;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class R<T> {

    private int code;
    private boolean success;
    private String message;
    private T data;

    public static R<?> success(String message) {
        return new R<Object>(2000, true, message, Collections.EMPTY_MAP);
    }

    public static <T> R<T> success(String message, T data) {
        return new R<T>(2000, true, message, data);
    }

    public static R<?> fail(String message) {
        return new R<Object>(4000, false, message, Collections.EMPTY_MAP);
    }

}
